const newLocal=this.
  ;
<template>
  <div class="login">
    <div class="login-header">
      <van-nav-bar class="login-bar" title="登录" @click-left="$router.back()" left-arrow />
    </div>
    <!-- 输入手机号，调起手机号键盘 -->
    <van-field v-model="tel" type="tel" placeholder="请输入手机号" />
    <!-- 输入密码 -->
    <van-field v-model="password" type="password" placeholder="请输入密码" />
    <div class="login-got">
      <div @click="gotPassword">忘记密码？</div>
      <div class="reg" @click="goReg">去注册</div>
    </div>

    <div class="login-btn2">
      <van-button type="primary" @click="getData()">登录</van-button>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      tel: "",

      password: "",
    };
  },

  methods: {
    //登录
    getData() {
      this.$http
        .post("/user/login", {
          username: this.tel,
          password: this.password,
        })
        .then((res) => {
          console.log(res);
          window.localStorage.setItem("token", res.data.token);
          window.localStorage.setItem("uid", res.data.uid);
          // window.localStorage.setItem('userInfo',res.data.userInfo)
          console.log(res.data);
          if (res.data.code == 1 || res.data.code == 0) {
            Toast("登录成功");
            this.$router.push("/");
          } else {
            Toast(res.data.msg);
          }
        });
    },
    goReg(){
      this.$router.push("/reg")
    },
    gotPassword(){
      this.$router.push("/gotPassword")
    }
  },
};
</script>

<style>
.login {
  position: relative;
}

.login-btn2 {
  position: absolute;
  left: 13px;
}
.login-btn2 button {
  width: 350px;
  text-align: center;
}

.login-bar {
  background: #07c060;
}
.login-btn1 {
  border-radius: 50px;
  height: 20px;
  width: 105px;
  background: #f5f6f7;
}
.login-got{
  position: relative;
  display: flex;
  margin: 15px;
  
}
.login-got .reg{
position: absolute;
right: 10px;
  }
.van-nav-bar__title {
  color: white;
}
</style>